<?php 
/*
Template Name: Software
*/
get_header(); ?>

<hr />

<div id="wrapper">
<div id="content">

<h2>Software List</h2>
<?php 
//Faccio la query per ritornare il custom post type "software" //TODO: traddurre in inglese!
			$type = 'software';
			$args=array(
				'post_type' => $type,
				'post_status' => 'publish',
				'paged' => $paged,
				'posts_per_page' => 10,
				'caller_get_posts'=> 1
			);
			$temp = $wp_query; //salvo query originale per recuperarla dopo //NOTICE: dopo quando??? refuso???
			$wp_query = null;
			$wp_query = new WP_Query($args);
			
		?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post_custom" id="post-<?php the_ID(); ?>">

	 <h3 class="storytitle"><?php the_title(); ?></h3>
<!--	<div class="meta"><span class="user"><?php the_author() ?> @ <?php the_time() ?></span> <?php edit_post_link(__('Edit This')); ?></div>
-->
	<div class="storycontent">
		<?php the_content(__('(more...)')); ?>
		<div class="post-details">
			<strong> Download Link: </strong> 
			<a href="<?php echo get_post_meta(get_the_ID(),'Download Link', true); ?>"><?php the_title(); ?></a>
		</div>
	</div>

</div>

<?php comments_template(); // Get wp-comments.php template ?>

<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

<?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>

<!-- Show application upload form only to registered users -->
<!-- REMINDER: upload dir is wordpress\wp-content\uploads\YEARY\MONTH -->
<!-- REMINDER: there is a list of allowed mime-types for upload in wordpress
http://howto.blbosti.com/2010/03/wordpress-modify-the-upload-list-of-allowed-file-types/
-->

<h2>Upload Section</h2>
<?php if ($user_ID != '') { ?>
<p>Here you can upload a document:</p>

<form method="post" action="/wordpress/wp-content/themes/stardust/addItem.php" enctype="multipart/form-data" >
	<p><label for="title">Title:</label><br /></p>
	<input type="text" id="title" value="Default Title" tabindex="1" size="40" name="title" />
	
	<p><label for="description">Description:</label><br /></p>
	<textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea>
	
    <p><label for="file">File:</label>
    <input id="file" type="file" name="uploaded_attachment">
    <input type="submit" value="Upload">
	
	<input type="hidden" name="post_type" id="post_type" value="software" />
	<input type="hidden" name="action" value="post" />
</form>
<?php } else { ?>
<p>Upload disabled. Log in to upload applications.</p>
<?php } ?>

<?php get_footer(); ?>